<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="cfn" uri="http://francetelecom.com/cfn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<%-- The component displaying the form errors. Parameters are:
    - code: the global errors message code
  --%>

<spring:bind path="*">
  <c:choose>
    <c:when test="${status.errors.globalErrorCount > 0}">
      <p class="formGlobalError">
          <%-- Getting the right error message --%>
          <c:set var="error" value="${status.errors.globalError}"/>
              ${error}
          <c:set var="errorMsg" value=""/>
          <c:forEach items="${error.codes}" var="code">
            <c:if test="${empty errorMsg}">
              <spring:theme var="errorMsg" code="${code}"
                arguments="${error.arguments}" text=""/>
            </c:if>
          </c:forEach>

          <c:if test="${not empty errorMsg}">
            ${errorMsg}
          </c:if>
      </p>
    </c:when>
    <c:when test="${status.errors.fieldErrorCount > 0}">
     <c:set var="error" value="${status.errors.fieldError}"/>
              ${error}
      <p class="formGlobalError"><spring:theme code="${param.code}"/></p>
    </c:when>
  </c:choose>
</spring:bind>